//
//  AppDelegate.m
//  AutoCompilerManager
//
//  Created by Vescky on 13-5-7.
//  Copyright (c) 2013年 Vescky. All rights reserved.
//

#import "AppDelegate.h"
#import "autoCompileServlet.h"
#import "AppsJsonEngine.h"
#import "ReadConfig.h"

@implementation AppDelegate
@synthesize tfWaitingNumber,mpServerIp;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
    
    mgServer = [[MongooseServer alloc] initWithPort:8081 allowDirectoryListing:YES];
    
    autoCompileServlet *servlet = [autoCompileServlet shareAutoCompilerServlet];
    [mgServer addServlet:servlet forPath:@"/autocompiler"];
    
    //初始化Engine
//    [AppsJsonEngine sharedEngine:[NSString stringWithFormat:@"%@/AppsPortlet/servlet",[ReadConfig readConfigByKey:@"SERVER_IP"]]];//192.168.1.107
    
    self.mpServerIp = [NSString stringWithFormat:@"http://%@/AppsPortlet/servlet/AutoComplier",[ReadConfig readConfigByKey:@"SERVER_IP"]];
    
    //每小时检查一次
    timerForLogSystem = [NSTimer scheduledTimerWithTimeInterval:60*60 target:self selector:@selector(checkLogSystem) userInfo:nil repeats:YES];
    [timerForLogSystem fire];
//    [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(logSth) userInfo:nil repeats:YES];
}

- (void)checkLogSystem {
    
    if ([[ReadConfig readConfigByKey:@"IS_LOG_ON"] isEqualToString:@"NO"]) {
        NSLog(@"log is down!");
    }
    else {
        [[LogSystem shareLogSystem] recordLogs];
    }
    
    
}

//- (void)logSth {
//    NSLog(@"%@",[NSDate date]);
//}

@end
